
#ifndef MODEL_BRIDGE_H
#define MODEL_BRIDGE_H

#include <vector>

#include "mvc/mymodel.h"

class ModelBridge: public MyModel {
  private:
    std::vector<MyModel*> members;
    std::vector<MyModel*> temp_members;

  public:

    void makeMembersPermanent() {
        for(int i = 0; i < temp_members.size(); i++) {
            members.push_back(temp_members[i]);
        }
        temp_members.clear();
    }
    void addMember(MyModel* val) {
        val->setParent(this);
        temp_members.push_back(val);
    }
    void removeMember(MyModel* val) {
        for(int i = 0; i < members.size(); i++) {
            if(members[i] == val) {
                members.erase(members.begin() + i);
                break;
            }
        }

        for(int i = 0; i < temp_members.size(); i++) {
            if(temp_members[i] == val) {
                temp_members.erase(temp_members.begin() + i);
                break;
            }
        }
    }

    virtual void kill() {

    }
};

#endif

